/*
 * MarcoBarra.java
 *
 * TODO: Descripcion
 *
 * Creado en 31 de diciembre de 2006, 12:11
 *
 * Copyright (C) 31 de diciembre de 2006, Protactino
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


package es.atareao.ferraplan.gui;
//
//********************************IMPORTACIONES*********************************
//
import com.eteks.parser.CompilationException;
import com.eteks.parser.CompiledFunction;
import com.eteks.parser.FunctionParser;
import es.atareao.alejandria.gui.ErrorDialog;
import es.atareao.alejandria.lib.Convert;
import es.atareao.ferraplan.lib.Barra;
import es.atareao.ferraplan.lib.Diametro;
import es.atareao.ferraplan.lib.Forma;
import es.atareao.ferraplan.lib.WrapperSVG;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JFrame;

/**
 *
 * @author  Protactino
 */
public class DialogBarra extends javax.swing.JDialog {
    //
    //********************************CONSTANTES********************************
    //
    /** A return status code - returned if Cancel button has been pressed */
    public static final int RET_CANCEL = 0;
    /** A return status code - returned if OK button has been pressed */
    public static final int RET_OK = 1;
    //
    public final static int OP_ADD=0;
    public final static int OP_EDIT=1;
    public final static int OP_DELETE=2;
    public final static int OP_VIEW=3;
    //
    //******************************CONSTRUCTORES*******************************
    //
    /**
     * Creates new form MarcoEmpresa
     * @param padre 
     * @param operacion 
     * @param empresa 
     * @throws java.sql.SQLException 
     */
    public DialogBarra(JFrame padre,int operacion,Barra barra) throws SQLException {
        super(padre,true);
        initComponents();
        this.setSize(520,670);
        this.setLocationRelativeTo(null);
        this.setOperacion(operacion);
        //
        switch (operacion){
            case OP_ADD:
                this.setTitle("Añadir Barra");
                break;
            case OP_EDIT:
                this.setTitle("Editar Barra");
                break;
            case OP_DELETE:
                this.setTitle("Borrar Barra");
                this.doNotEditable();
                break;
            case OP_VIEW:
                this.setTitle("Consultar Barra");
                this.doNotEditable();
                break;
        }
        //
        Diametro dn=new Diametro(barra.getConector());
        this.jDiametro.setElements(dn.findAll());
        this.jDiametro.setSelectedIndex(0);
        Forma forma=new Forma(barra.getConector());
        Vector<WrapperSVG> wsvg=forma.findAllWraperSVG();
        if(!wsvg.isEmpty()){
            this.jForma.setElements(forma.findAllWraperSVG());
            this.jForma.setSelectedIndex(0);
        }
        //
        this.setBarra(barra);
    }
    
    public DialogBarra(int operacion,Barra barra) throws SQLException{
        this(new JFrame(),operacion,barra);
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jAceptar = new javax.swing.JButton();
        jCancelar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jA = new es.atareao.alejandria.gui.JNumericField();
        jB = new es.atareao.alejandria.gui.JNumericField();
        jC = new es.atareao.alejandria.gui.JNumericField();
        jD = new es.atareao.alejandria.gui.JNumericField();
        jE = new es.atareao.alejandria.gui.JNumericField();
        jF = new es.atareao.alejandria.gui.JNumericField();
        jG = new es.atareao.alejandria.gui.JNumericField();
        jH = new es.atareao.alejandria.gui.JNumericField();
        jI = new es.atareao.alejandria.gui.JNumericField();
        jJ = new es.atareao.alejandria.gui.JNumericField();
        jLabel17 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jComentario = new javax.swing.JTextArea();
        jReferencia = new javax.swing.JTextField();
        jCantidad = new es.atareao.alejandria.gui.JNumericField();
        jLongitud = new es.atareao.alejandria.gui.JNumericField();
        jPesoUnitario = new es.atareao.alejandria.gui.JNumericField();
        jPesoTotal = new es.atareao.alejandria.gui.JNumericField();
        jDiametro = new es.atareao.queensboro.gui.JWrapperComboBox();
        jForma = new es.atareao.ferraplan.gui.JWrapperSVGImageComboBox();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jAceptar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/es/atareao/img/png/button_ok.png"))); // NOI18N
        jAceptar.setBorderPainted(false);
        jAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAceptarActionPerformed(evt);
            }
        });
        getContentPane().add(jAceptar, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 570, 50, 50));

        jCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/es/atareao/img/png/button_cancel.png"))); // NOI18N
        jCancelar.setBorderPainted(false);
        jCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCancelarActionPerformed(evt);
            }
        });
        getContentPane().add(jCancelar, new org.netbeans.lib.awtextra.AbsoluteConstraints(450, 570, 50, 50));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel2.setText("Diametro:");
        jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 90, 30));

        jLabel3.setText("Forma:");
        jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 90, 90));

        jLabel13.setText("Cantidad:");
        jPanel1.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 430, 90, 30));

        jLabel14.setText("Longitud:");
        jPanel1.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 460, 90, 30));

        jLabel15.setText("Peso unitario:");
        jPanel1.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 490, 90, 30));

        jLabel16.setText("Peso total:");
        jPanel1.add(jLabel16, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 520, 90, 30));

        jLabel19.setText("Referencia:");
        jPanel1.add(jLabel19, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 90, 30));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Dimensiones"));
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setText("A:");
        jPanel2.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 20, 30));

        jLabel4.setText("B:");
        jPanel2.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 20, 20, 30));

        jLabel5.setText("C:");
        jPanel2.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 20, 20, 30));

        jLabel6.setText("D:");
        jPanel2.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 20, 20, 30));

        jLabel7.setText("E:");
        jPanel2.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 20, 20, 30));

        jLabel8.setText("F:");
        jPanel2.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, 20, 30));

        jLabel9.setText("G:");
        jPanel2.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70, 20, 30));

        jLabel10.setText("H:");
        jPanel2.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(190, 70, 20, 30));

        jLabel11.setText("I:");
        jPanel2.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(280, 70, 20, 30));

        jLabel12.setText("J:");
        jPanel2.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 70, 20, 30));
        jPanel2.add(jA, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, 60, 30));
        jPanel2.add(jB, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 20, 60, 30));
        jPanel2.add(jC, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 20, 60, 30));
        jPanel2.add(jD, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 20, 60, 30));
        jPanel2.add(jE, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 20, 60, 30));
        jPanel2.add(jF, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 70, 60, 30));
        jPanel2.add(jG, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 70, 60, 30));
        jPanel2.add(jH, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 70, 60, 30));
        jPanel2.add(jI, new org.netbeans.lib.awtextra.AbsoluteConstraints(300, 70, 60, 30));
        jPanel2.add(jJ, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 70, 60, 30));

        jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 470, 120));

        jLabel17.setText("Comentario:");
        jPanel1.add(jLabel17, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 310, 90, 20));

        jComentario.setColumns(20);
        jComentario.setRows(5);
        jScrollPane1.setViewportView(jComentario);

        jPanel1.add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 307, 370, 110));
        jPanel1.add(jReferencia, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 10, 360, -1));
        jPanel1.add(jCantidad, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 430, 370, 30));
        jPanel1.add(jLongitud, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 460, 370, 30));
        jPanel1.add(jPesoUnitario, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 490, 370, 30));
        jPanel1.add(jPesoTotal, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 520, 370, 30));
        jPanel1.add(jDiametro, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 50, 360, -1));

        jForma.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jPanel1.add(jForma, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 90, 360, 90));

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, 490, 560));

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/es/atareao/img/png/button_calculate.png"))); // NOI18N
        jButton1.setBorderPainted(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(350, 570, 50, 50));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Forma forma=(Forma)this.jForma.getSelectedItem();
        String formula=forma.getValue("formula");
        /*
        String function="f(";
        ArrayList<Double> valores=new ArrayList<Double>();
        if(Convert.toBoolean(forma.getValue("a"))){
            function+="a,";
            valores.add(this.jA.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("b"))){
            function+="b,";
            valores.add(this.jB.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("c"))){
            function+="c,";
            valores.add(this.jC.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("d"))){
            function+="d,";
            valores.add(this.jD.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("e"))){
            function+="e,";
            valores.add(this.jE.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("f"))){
            function+="f,";
            valores.add(this.jF.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("g"))){
            function+="g,";
            valores.add(this.jG.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("h"))){
            function+="h,";
            valores.add(this.jH.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("i"))){
            function+="i,";
            valores.add(this.jI.getDouble());
        }
        if(Convert.toBoolean(forma.getValue("j"))){
            function+="j";
            valores.add(this.jJ.getDouble());
        }
        if(function.endsWith(",")){
            function=function.substring(0,function.length()-1)+") = "+formula;
        }
        double[] valoresd = new double[valores.size()];
        for(int contador=0;contador<valores.size();contador++){
            valoresd[contador]=Convert.toDouble(valores.get(contador));
        }
        */
        String function="f(a,b,c,d,e,f,g,h,i,j) = "+formula;
        double[] valoresd = new double[10];
        valoresd[0]=this.jA.getDouble();
        valoresd[1]=this.jA.getDouble();
        valoresd[2]=this.jA.getDouble();
        valoresd[3]=this.jA.getDouble();
        valoresd[4]=this.jA.getDouble();
        valoresd[5]=this.jA.getDouble();
        valoresd[6]=this.jA.getDouble();
        valoresd[7]=this.jA.getDouble();
        valoresd[8]=this.jA.getDouble();
        valoresd[9]=this.jA.getDouble();
        try {
            FunctionParser parser = new FunctionParser ();
            CompiledFunction cfunction = parser.compileFunction(function);
            double longitudtotal = cfunction.computeFunction (valoresd);
            jLongitud.setDouble(longitudtotal);
            Diametro d=(Diametro)jDiametro.getSelectedItem();
            double pesometro=Convert.toDouble(d.getValue("peso"));
            jPesoUnitario.setDouble(pesometro*longitudtotal);
            jPesoTotal.setDouble(jCantidad.getDouble()*jPesoUnitario.getDouble());
        } catch (CompilationException ex) {
            ErrorDialog.manejaError(ex,false);
        }
    }//GEN-LAST:event_jButton1ActionPerformed
    
    private void jCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelarActionPerformed
// TODO add your handling code here:
        doClose(RET_CANCEL);
    }//GEN-LAST:event_jCancelarActionPerformed
    
    private void jAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAceptarActionPerformed
// TODO add your handling code here:
        doClose(RET_OK);
    }//GEN-LAST:event_jAceptarActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private es.atareao.alejandria.gui.JNumericField jA;
    private javax.swing.JButton jAceptar;
    private es.atareao.alejandria.gui.JNumericField jB;
    private javax.swing.JButton jButton1;
    private es.atareao.alejandria.gui.JNumericField jC;
    private javax.swing.JButton jCancelar;
    private es.atareao.alejandria.gui.JNumericField jCantidad;
    private javax.swing.JTextArea jComentario;
    private es.atareao.alejandria.gui.JNumericField jD;
    private es.atareao.queensboro.gui.JWrapperComboBox jDiametro;
    private es.atareao.alejandria.gui.JNumericField jE;
    private es.atareao.alejandria.gui.JNumericField jF;
    private es.atareao.ferraplan.gui.JWrapperSVGImageComboBox jForma;
    private es.atareao.alejandria.gui.JNumericField jG;
    private es.atareao.alejandria.gui.JNumericField jH;
    private es.atareao.alejandria.gui.JNumericField jI;
    private es.atareao.alejandria.gui.JNumericField jJ;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private es.atareao.alejandria.gui.JNumericField jLongitud;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private es.atareao.alejandria.gui.JNumericField jPesoTotal;
    private es.atareao.alejandria.gui.JNumericField jPesoUnitario;
    private javax.swing.JTextField jReferencia;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
    //
    // *********************************CAMPOS*********************************
    //
    private int _returnStatus = RET_CANCEL;
    private int _operacion;
    private Barra _barra;
    //
    //********************************METODOS***********************************
    //
    
    //
    //**************************METODOS AUXILIARES******************************
    //
    private void doClose(int retStatus) {
        if(retStatus==RET_OK){
            try {
                if(this.fromDialog().validate()){
                    this.setBarra(this.fromDialog());
                }
            } catch (Exception ex) {
                 ErrorDialog.manejaError(ex,false);
            }
        }
        this.setReturnStatus(retStatus);
        setVisible(false);
        dispose();
    }    

    private void doNotEditable(){
        this.jReferencia.setEditable(false);
        this.jDiametro.setEnabled(false);
        this.jForma.setEnabled(false);
        this.jA.setEditable(false);
        this.jB.setEditable(false);
        this.jC.setEditable(false);
        this.jD.setEditable(false);
        this.jE.setEditable(false);
        this.jF.setEditable(false);
        this.jG.setEditable(false);
        this.jH.setEditable(false);
        this.jI.setEditable(false);
        this.jJ.setEditable(false);
        this.jComentario.setEditable(false);
        this.jCantidad.setEditable(false);
        this.jLongitud.setEditable(false);
        this.jPesoUnitario.setEditable(false);
        this.jPesoTotal.setEditable(false);
        //
        this.jReferencia.setBackground(java.awt.SystemColor.info);
        this.jDiametro.setBackground(java.awt.SystemColor.info);
        this.jForma.setBackground(java.awt.SystemColor.info);
        this.jA.setBackground(java.awt.SystemColor.info);
        this.jB.setBackground(java.awt.SystemColor.info);
        this.jC.setBackground(java.awt.SystemColor.info);
        this.jD.setBackground(java.awt.SystemColor.info);
        this.jE.setBackground(java.awt.SystemColor.info);
        this.jF.setBackground(java.awt.SystemColor.info);
        this.jG.setBackground(java.awt.SystemColor.info);
        this.jH.setBackground(java.awt.SystemColor.info);
        this.jI.setBackground(java.awt.SystemColor.info);
        this.jJ.setBackground(java.awt.SystemColor.info);
        this.jComentario.setBackground(java.awt.SystemColor.info);
        this.jCantidad.setBackground(java.awt.SystemColor.info);
        this.jLongitud.setBackground(java.awt.SystemColor.info);
        this.jPesoUnitario.setBackground(java.awt.SystemColor.info);
        this.jPesoTotal.setBackground(java.awt.SystemColor.info);
    }
    
    private Barra fromDialog(){
        String referencia=jReferencia.getText();
        String diametro=this.jDiametro.getSelectedId();
        String forma=this.jForma.getSelectedId();
        String a=jA.getText();
        String b=jB.getText();
        String c=jC.getText();
        String d=jD.getText();
        String e=jE.getText();
        String f=jF.getText();
        String g=jG.getText();
        String h=jH.getText();
        String i=jI.getText();
        String j=jJ.getText();
        String comentario=jComentario.getText();
        String cantidad=this.jCantidad.getText();
        String longitud=this.jLongitud.getText();
        String peso_unitario=this.jPesoUnitario.getText();
        String peso_total=this.jPesoTotal.getText();
        //
        this.getBarra().setValue("referencia",referencia);
        this.getBarra().setValue("diametro_id",diametro);
        this.getBarra().setValue("forma_id",forma);
        this.getBarra().setValue("a",a);
        this.getBarra().setValue("b",b);
        this.getBarra().setValue("c",c);
        this.getBarra().setValue("d",d);
        this.getBarra().setValue("e",e);
        this.getBarra().setValue("f",f);
        this.getBarra().setValue("g",g);
        this.getBarra().setValue("h",h);
        this.getBarra().setValue("i",i);
        this.getBarra().setValue("j",j);
        this.getBarra().setValue("comentario",comentario);
        this.getBarra().setValue("cantidad",cantidad);
        this.getBarra().setValue("longitud",longitud);
        this.getBarra().setValue("peso_unitario",peso_unitario);
        this.getBarra().setValue("peso_total",peso_total);
        return this.getBarra();
    }
    private void toDialog(Barra barra){
        String referencia=barra.getValue("referencia");
        String acero=barra.getValue("acero_id");
        String diametro=barra.getValue("diametro_id");
        String forma=barra.getValue("forma_id");
        String a=barra.getValue("a");
        String b=barra.getValue("b");
        String c=barra.getValue("c");
        String d=barra.getValue("d");
        String e=barra.getValue("e");
        String f=barra.getValue("f");
        String g=barra.getValue("g");
        String h=barra.getValue("h");
        String i=barra.getValue("i");
        String j=barra.getValue("j");
        String comentario=barra.getValue("comentario");
        String numero=barra.getValue("cantidad");
        String longitud=barra.getValue("longitud");
        String peso_unitario=barra.getValue("peso_unitario");
        String peso_total=barra.getValue("peso_total");
        this.jReferencia.setText(referencia);
        this.jDiametro.setSelectedId(diametro);
        this.jForma.setSelectedId(forma);
        this.jA.setText(a);
        this.jB.setText(b);
        this.jC.setText(c);
        this.jD.setText(d);
        this.jE.setText(e);
        this.jF.setText(f);
        this.jG.setText(g);
        this.jH.setText(h);
        this.jI.setText(i);
        this.jJ.setText(j);
        this.jComentario.setText(comentario);
        this.jCantidad.setText(numero);
        this.jLongitud.setText(longitud);
        this.jPesoUnitario.setText(peso_unitario);
        this.jPesoTotal.setText(peso_total);
    } 
    
    //
    //**************************METODOS DE ACCESO*******************************
    //
    
    public int getReturnStatus() {
        return _returnStatus;
    }
    
    public void setReturnStatus(int returnStatus) {
        this._returnStatus = returnStatus;
    }
    
    public int getOperacion() {
        return _operacion;
    }

    public void setOperacion(int operacion) {
        this._operacion = operacion;
    }

    public Barra getBarra() {
        return _barra;
    }

    public void setBarra(Barra barra) {
        this._barra = barra;
        this.toDialog(barra);
    }
    
}
